import os
import fitz 

def covert2Images(file_path, zoom, png_path):
    doc = fitz.open(file_path)
    total = doc.page_count
    for pg in range(total):
        page = doc[pg]
        # 值越大，分辨率越高，文件越清晰
        zoom = int(zoom)  
        rotate = int(0)

        trans = fitz.Matrix(zoom / 100.0, zoom / 100.0).prerotate(rotate)
        pm = page.get_pixmap(matrix=trans, alpha=False)
        if not os.path.exists(png_path):
            os.mkdir(png_path)
        save = os.path.join(png_path, '%s.jpg' %(pg+1))
        pm.save(save)
    doc.close()

if __name__ == "__main__":
    pdfPath = './软件开发成本度量实施规程.pdf'
    imagePath = './imgs'
    covert2Images(pdfPath, 200, imagePath)